package com.charon.common.websocket;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * @ClassName：WebSocketConfig.java
 * @Description: WebSocket配置
 * @Author charon [248135724@qq.com]
 * @Date:   2018年11月16日 下午8:50:09 
 * @version V1.0 
 */

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(socketHandler(), "/charon");
    }

    @Bean
    public WebSocketHandler socketHandler() {
        return new SocketHandler();
    }

}
